package com.example.demo.controller;

import com.example.demo.common.ResultAjax;
import com.example.demo.model.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/getuser")
    public ResultAjax getUser(){
        System.out.println("do getUser()");
        return ResultAjax.succ("user");
    }

    @RequestMapping("/reg")
    public ResultAjax reg(){
        System.out.println("do reg()");
        Object obj=null;
        System.out.println(obj.hashCode());
        return ResultAjax.succ("reg");
    }

    @RequestMapping("/login")
    public ResultAjax login(){
        System.out.println("do login()");
        int num=10/0;
        return ResultAjax.succ("login");
    }

    @RequestMapping("/getnum")
    public int getNum(){
        return 1;
    }

    @RequestMapping("/getstr")
    public String getStr(){
        return "hello";
    }
    
    @RequestMapping("/user")
    public User user(){
        User user=new User();
        user.setId(1);
        user.setName("张三");
        user.setPassword("123");
        return user;
    }
}
